<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<html>
<head>
    <script type="text/javascript">
        function doSearch() {
        	grid.load({
                ins_uuid : $('#ins_uuid').val(),
                profit_type: $("#profit_type").val()
            });
        }

        function addCustomProfit(url){
            commonDetail(url,"save","customProfitTableId");
        }
        function modifyCustomProfit(url){
            commonDetail(url,"update","customProfitTableId");
        }
        
        function showCustomProfitd(url){
            commonDetail(url,"detail","customProfitTableId");
        }
        /*删除分润设置信息*/
        function deleteCustomProfit(url){
        	commonDel(url,'', "customProfitTableId");
        }
		var grid;
        $(document).ready(function() {
            var ztreeObj;
            /*选择按钮*/
            $("#selelctBtn").click(function(){
            	var option = {url:'../insinf/getDirectInsInfTree.do'};
                ztreeObj = showInsTree(selected, null, option);
            });

            /*确定按钮回调*/
            function selected(){
                var nodes = ztreeObj.getSelectedNodes();
                console.log(nodes);
                if(nodes && nodes.length > 0){
                	$("#ins_uuid").textbox("setValue", null);
                    $("#ins_uuid").textbox("setValue", nodes[0].NAME);
                    $("#ins_uuid").val(nodes[0].ID);
                }
            }

            grid = $("#customProfitTableId").jpgrid({
                url: "getCustomProfitListJson.do",
                columns: [
                    {title: "所属机构", field: "INS_CD_NAME",width:120},
                    {title: "当前会员级别", field: "CUR_CUSTOM_LEVEL",width:120},
                    {title: "直接推荐人会员级别", field: "DIRECT_CUSTOM_LEVEL",width:120},
                    {title: "间接推荐人会员级别", field: "INDIRECT_CUSTOM_LEVEL",width:120},
                    {title: "分润方式", field: "PROFIT_MODE",width:120},
                    {title: "分润类型", field: "PROFIT_TYPE",width:120},
                    {title: "当前会员获利金额(比例)", field: "CUR_COMM",width:120},
                    {title: "直接推荐人获利金额(比例)", field: "DIRECT_COMM",width:120},
                    {title: "间接推荐人获利金额(比例)", field: "INDIRECT_COMM",width:120}
                ]
            });
        });
    </script>
</head>
<body class="easyui-layout list_body">
<form id="customProfitForm" name="customProfitForm" >
	<div class="list_body_north" data-options="region:'north'" border="false">
	    <!-- 查询表单 -->
	    <div  class="datagrid-toolbar" border="false"  >
	        <div id="menuTree">
	            <div id="ztreeObj" class="ztree"></div>
	        </div>
	        <div>
	            <span>所属机构:</span>
	            <input class="easyui-textbox" type="text" readonly="readonly" id="ins_uuid" name="ins_uuid"/>
	            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="selelctBtn">选择</a>
	            <span>分润类型:</span>
	            <code:codeSelect name="profit_type" id="profit_type" code_type="PROFIT_TYPE" showSelect="true"></code:codeSelect>
	            <a href="#" class="easyui-linkbutton btn" iconCls="icon-search" onclick="doSearch() ">查询</a>
	            <a href="#" class="easyui-linkbutton btn" iconCls="icon-reload" onclick="resetForm() ">重置</a>
	        </div>
	    </div>
	    <!-- 自定义标签工具栏 -->
	    <jiepos:buttonOperateTag menuCode="${menuCode}"></jiepos:buttonOperateTag>
	</div>
    <div data-options="region:'center'" border="false" class="list_body_center">
	    <!-- 表格 -->
	    <table id="customProfitTableId" fit="true"></table>
    </div>
</form>
</body>
</html>
